package com.hsy.baoinbao.modules.notice.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.deparse.dpframe.ui.adapter.DPBaseAdapter;
import com.hsy.baoinbao.R;
import com.hsy.baoinbao.modules.notice.gsondata.NoticeListData;

import java.util.List;

/**
 * Created by hsy on 2016/3/24.
 */
public class NoticeAdapter extends DPBaseAdapter<NoticeListData.Lists> {
    private LayoutInflater inflater;

    public NoticeAdapter(Context context) {
        super();
        init(context);
    }

    public NoticeAdapter(Context context, List<NoticeListData.Lists> data) {
        super(data);
        init(context);
    }

    private void init(Context context) {
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public CommonBaseViewHolder<NoticeListData.Lists> getHolder(int position) {
        return new ViewHolder();
    }

    class ViewHolder extends CommonBaseViewHolder<NoticeListData.Lists> {
        private TextView mTitleTextView;
        private TextView mDateTextView;
        private TextView mContentTextView;

        @Override
        public View create(int position) {
            View view = inflater.inflate(R.layout.item_notice_list, null);
            mTitleTextView = (TextView) view.findViewById(R.id.title);
            mDateTextView = (TextView) view.findViewById(R.id.date);
            mContentTextView = (TextView) view.findViewById(R.id.content);
            return view;
        }

        @Override
        public void update(NoticeListData.Lists data) {
            mTitleTextView.setText(data.getName());
            mDateTextView.setText(data.getDate());
            mContentTextView.setText(data.getContext());
        }
    }
}
